import { ref } from 'vue';
const APPROVAL_STATUS = {
    UNEDITED: '0',
    APPROVED: '1',
    REJECTED: '3'
};
const useWarehouseEntry = () => {
    const { proxy } = getCurrentInstance() as ComponentInternalInstance;

    const libraryVisible = ref(false);
    const libraryObj = ref<any>();

    /**
     * @description: 打开入库弹窗
     */
    const handleOpenLibrary = (row: any) => {
        const { approvalStatus, inStatus } = row;
        switch (approvalStatus) {
            case APPROVAL_STATUS.UNEDITED:
                return proxy?.$modal.msgError('福利采购单未被编辑，无法入库!');
            case APPROVAL_STATUS.APPROVED:
                return proxy?.$modal.msgError('福利采购单未被审核，无法入库!');
            case APPROVAL_STATUS.REJECTED:
                return proxy?.$modal.msgError('福利采购单审核已被拒绝，无法入库!');
        }

        if( inStatus === '2') return proxy?.$modal.msgError('福利采购单已被入库，无法再次入库!');

        libraryObj.value = row;
        libraryVisible.value = true;
    };



    return {
        libraryVisible,
        libraryObj,
        handleOpenLibrary
    }
};

export default useWarehouseEntry;